home *** CD-ROM | disk | FTP | other *** search
- /*
- File: CoreSample.h
-
- Contains: An application that is Apple Event-aware, Scripting Compatible,
- and recordable. It supports the Required and Core Suite of
- Apple Events, the Object Model, and the Open Scripting
- Architecture.
-
- The main purpose of this sample code is to demonstrate how to develop an
- application that is Apple event-aware, scripting compatible, uses the Object
- Support Library, and supports Apple's Open Scripting Architecture. In
- addition, it has its own 'aete' (Apple Event Terminology Extension) resource
- (CoreSampleAETE.r). By incorporating these technologies into your application,
- your application will support Apple's Open Scripting Architecture.
-
- The functionality of CoreSample is basic window manipulation. The user may
- create, drag, size, zoom, and close windows. All these actions may be
- performed through Apple events.
-
- This application is also "factored", which means that user interactions (such
- as dragging or sizing a window, selecting a menuitem) are converted into Apple
- events which the application sends off to itself, and then is handled by the
- corresponding event handler. Factoring makes it possible to access the appli-
- cation's functionality through Apple events. It also makes it easier to record
- the user's actions in the form of Apple events.
-
- CoreSample supports the Required and Core suites of events, and the application
- and window object classes. One additional property has been added to the window
- class, and that is its position, the top left-hand coordinates of the window.
- Some events only apply to the window class, such as Create, Move, Clone, and
- Set Data (application properties are not modifiable, except for pClipboard,
- which I do not support). Currently, CoreSample supports the Simple Grammar,
- as defined in the "Object Support Library Developer Note".
-
- The properties you may access with the Get Data Apple event are as follows:
- Application - Best Type, Default Type, Class, Name, IsFrontProcess, Version
- Window - Best Type, Default Type, Bounds, Class, Index, Name, Position,
- Closeable, Titled, Resizable, Zoomable, Floating, Modal, Zoomed,
- and Visible.
- The properties you may set with the Set Data Apple event are as follows:
- Window - Bounds, Index, Zoomed, Name, Position, and Visible.
-
- When you create a new element, you may pass it initial data values. This
- application will create the new element accordingly if either or both of the
- initial data parameters exist. In addition, with CoreSample, you may create or
- move a window without passing it an insertion location record. By default, a
- window will be created/moved to the frontmost position.
-
- (NOTE: Some portions of this code are derived from TESample, a
- sample application provided by Apple Developer Technical Support.)
-
- Written by: Sue Dumont
-
- Copyright: Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/21/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
- 12/1/93 <dan> added PowerPC support - will run native on PowerPC if
- compiled on PowerPC system. These changes are denoted
- by [pwpc].
- 6/22/93 <doo> converted files to run in the Think C 6.0 environment
- Fixed incorrect comparison of rects and windowlist problems
- associated with the Think compiler.
- 4/02.93 <smd> added GetWindowBounds routine to calculate the correct
- bounds when the bounds accessed from the content region is
- invalid (such as when the application is hidden).
- - cleaned up the aete.
- 10/01/92 <smd> Added pVersion to application and now set the port before
- setting the pPosition property.
- 07/19/92 <smd> Fixed bug where the Move event was not recording the
- correct window being moved when the data was being passed
- by index rather than by name.
- 04/30/92 <smd> Check if replacing the same window in HandleMove
- (i.e., "move window 2 to window 2"). If so, do nothing.
- 06/25/92 <smd> Changed FindRelativeWindow to return the windowPtr of the
- window being replaced rather than closing it. This caused
- an error when trying to replace the same window, in which
- case nothing should happen. (Ex. move window 2 to window 2).
- 04/27/92 <smd> Fixed bug in DoSetData where data was set to a pointer, and
- then the pointer was diposed of.
- 04/20/92 <smd> Fixed a bug with setting the visibility property of a window.
- 02/28/92 <smd> Added coercion routines (thanks Kevin) to clean up code.
- These convert from descs to boolean, long, and pstrings.
- 02/25/92 <smd> Modified GetWindowWithTitle, GetWidnowWithIndex, and
- GetWindowIndexNum routines to use WindowList so ALL windows
- will be accessed (even invisible ones).
- - Changed InitializeDescs to MyInitDescs and DisposeDescs to
- MyDisposeDescs.
- - Removed the FailIfErr calls from the AE Handlers so that
- they will return the error code rather than dying.
- 02/24/92 <smd> Now sends a Move event when just making a window active.
- This is done in the DoEvent routine, drag region.
- 02/21/92 <smd> Fixed bug where the same AEDesc was being passed as source
- and dest to AECoerceDesc().
- Send myself a Move event when user clicks in content of a
- window.
- 02/17/92 <smd> Added InitializeDescs() and DisposeDescs() routines.
- 02/05/92 <smd> Handling optional parameters in Create Element event.
- 01/30/92 <smd> Adding complete support for core suite and properties.
- 01/21/92 <smd> Positive and negative offset when referencing by index.
- 01/10/92 <smd> Made insertion location parameter optional in the Create
- and Move events, and provided my own default behavior.
- 01/09/92 <kc> Quick clean up for Scripting QuickStart.
- 01/06/92 <kc> Added code for Count Elements, Do Objects Exist, Move,
- and Get Data Size
- 11/91 <smd> Initial code implementation.
-
- */
-
- #define pPosition 'ppos' // Position property code id for window.
- #define kAEDontExecute 0x00002000L // Flag used for smart recording.
- #define kCoreSampleID 'smpl' // suite id code for CoreSample
-
- #define kNameKeyForm 1 // Indicates formName for object specifier.
- #define kIndexKeyForm 2 // Indicates formAbsolutePosition.
- #define kEndOfList nil // Nil terminator for variable argument list.
-
-
- // Menu Items.
- #define mApple 128 // Apple menu
- #define iAbout 1
- #define mFile 129 // File menu
- #define iNew 1
- #define iClose 4
- #define iQuit 8
- #define mEdit 130 // Edit menu
- #define iUndo 1
- #define iCut 3
- #define iCopy 4
- #define iPaste 5
- #define iClear 6
-
- #define kDITop 0x0050 // Disk event dialog
- #define kDILeft 0x0070 // box data.
- #define kMaxStringSize 255 // Max # characters in string.
- #define kMinWinDim 64 // Minimum size of a window.
- #define kSysEnvironsVersion 1 // SysEnvRec version.
- #define kOSEvent app4Evt // Event used by MultiFinder.
- #define kSuspendResumeMessage 1 // High byte of suspend/resume event message.
- #define kResumeMask 1 // Bit of message field for resume vs. suspend.
- #define kMouseMovedMessage 0xFA // High byte of mouse-moved event message.
- #define kNoEvents 0 // No events mask.
-
- // Min result from the equation: ORD(GetApplLimit) - ORD(ApplicZone)
- #define kMinHeap (29 * 1024) // Min size of memory.
- // Min result from PurgeSpace when called at initialization time.
- #define kMinSpace (20 * 1024)
- #define kPrefSize 100 // Preferred heap size.
- #define kMinSize 60 // Minimum heap size.
-
- // The following are indicies into STR# resources.
- #define eWrongMachine 1
- #define eSmallSize 2
- #define eNoMemory 3
- #define eAEError 4
-
- #define rMenuBar 128 // application's menu bar
- #define rAboutAlert 128 // about alert
- #define rUserAlert 129 // user error alert
- #define rDocWindow 128 // application's window
- #define kErrStrings 128 // error string list
-
- // Data used in CoreSample.c
- #define kMaxOpenWindows 45 // Max # windows open.
- #define kMaxStrSize 255 // Max # characters in string.
-